package com.eis.persist.dao.util;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

public class GroupFunctionBatchSetter implements BatchPreparedStatementSetter {
	private List<String> functionIds;
	private List<Integer> functionLayouts;
	private int bizGroupId;
	private String userName;
	
	public GroupFunctionBatchSetter(List<String> functionIds, List<Integer> functionLayouts, int bizGroupId, String userName) {
		this.functionIds = functionIds;
		this.bizGroupId = bizGroupId;
		this.userName = userName;
		this.functionLayouts = functionLayouts;
	}

	@Override
	public void setValues(PreparedStatement ps, int i) throws SQLException {
		ps.setString(1, functionIds.get(i));
		ps.setInt(2, bizGroupId);
		ps.setInt(3,  functionLayouts.get(i));
		ps.setString(4, userName);
	}

	@Override
	public int getBatchSize() {
		if (functionIds != null) {
			return functionIds.size();
		} else {
			return 0;
		}
	}

}
